<?php

namespace App\Admin\Actions\Grid\RowActions;

use App\Models\Project;
use App\Models\ProjectAgreement;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;

class UpdateInfoEnd extends RowAction
{
    protected $title = '   <i class="feather icon-alert-octagon text-custom"></i> <span class="text-custom" title="">更新信息完结</span> &emsp;';

    /**
     * Handle the action request.
     *
     * @param Request $request
     *
     * @return Response
     */
    public function handle(Request $request)
    {
        $id = $request->input('id');
        $projectModel = Project::where('id', $id)->first();
        $projectModel->update_info_end = 1;
        $projectModel->save();

        return $this->response()->success('处理成功')->refresh();
    }


    public function confirm()
    {

        $projectModel = Project::where('id', $this->row()->id)->first();
        return ['确认《' . $projectModel['project_name'] . '》项目资料已经更新完毕了吗？'];
    }

    /**
     * 设置要POST到接口的数据
     *
     * @return array
     */
    public function parameters()
    {
        return [
            // 发送当前行 username 字段数据到接口
            'id' => $this->row->id,
        ];
    }
}
